home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / clang / vecpro11.zip / VECPROCP.H < prev    next >
Text File  |  1994-10-11  |  18KB  |  258 lines

  1. //
  2. //    VECPRO.H    Vector Pro Header File
  3. //
  4. //    Copyright 1994 by Vector Numerics, Inc.
  5. //
  6.  
  7. #include "math.h"
  8. #include "float.h"
  9. #include "stdlib.h"
  10. #include "errno.h"
  11.  
  12. #ifndef _VECTOR_PRO_DEFINED
  13. #define _VECTOR_PRO_DEFINED         /* avoid multiple def's  */
  14.  
  15. struct tenbytes
  16.     {
  17.     double r;
  18.     short s;
  19.     };
  20.  
  21. #ifndef    POLYNOMIAL_MAX_ORDER
  22. #define POLYNOMIAL_MAX_ORDER    20
  23. #endif
  24.  
  25. extern "C" short vp_poly_max_order;
  26. extern "C" double vp_pi;
  27.  
  28. struct poly
  29.     {
  30.     short order;
  31.     char waste[6]; // To force efficient data alignment in memory.
  32.     double co[POLYNOMIAL_MAX_ORDER + 1];
  33.     };
  34.  
  35. struct polyx
  36.     {
  37.     short order;
  38.     char waste[6]; // To force efficient data alignment in memory.
  39.     struct _complex co[POLYNOMIAL_MAX_ORDER + 1];
  40.     };
  41.  
  42. // Error Return Codes:
  43. //
  44. #define        VP_DIV_BY_0        1
  45. #define        VP_INFINITY        2
  46. #define        VP_OVERFLOW        3
  47. #define        VP_UNDERFLOW        4
  48. #define        VP_SINGULAR        5
  49. #define        VP_OUT_OF_RANGE        6
  50. #define        VP_PARAM_ERROR        7
  51. #define        VP_ILL_CONDITIONED    8
  52. #define        VP_COMPLEX_RESULT    9
  53. #define        VP_INTERNAL_ERROR    10
  54. #define        VP_NO_CONVERGENCE    11
  55. #define        VP_ACC_PLOSS        12
  56. #define        VP_ACC_TLOSS        13
  57. #define        VP_DUPLICATES        14
  58. #define        VP_UNSORTED        15
  59. #define        VP_EXTRAPOLATED        16
  60.  
  61.  
  62. extern "C" short    vecinit(short poly_max_order);
  63. extern "C" short    sincos(double theta, double * s, double * c);
  64. extern "C" short     cpx_add(struct _complex * r, struct _complex * a, struct _complex * b);
  65. extern "C" short     cpx_sub(struct _complex * r, struct _complex * a, struct _complex * b);
  66. extern "C" short     cpx_mult(struct _complex * r, struct _complex * a, struct _complex * b);
  67. extern "C" short     cpx_div(struct _complex * r, struct _complex * a, struct _complex * b);
  68. extern "C" short    cpx_abs(double * a, struct _complex * c);
  69. extern "C" short    cpx_arg(double * a, struct _complex * c);
  70. extern "C" short    cpx_convert(struct _complex * c, double abs, double arg);
  71. extern "C" short     cpx_sqrt(struct _complex * r, struct _complex * a);
  72. extern "C" short     cpx_power(struct _complex * r, struct _complex * a, double exp);
  73. extern "C" short     cpx_cpx_power(struct _complex * r, struct _complex * a, struct _complex * exp);
  74. extern "C" short    cpx_exp(struct _complex * r, struct _complex * a);
  75. extern "C" short     cpx_ln(struct _complex * r, struct _complex * a);
  76. extern "C" short     cpx_sin(struct _complex * r, struct _complex * a);
  77. extern "C" short     cpx_cos(struct _complex * r, struct _complex * a);
  78. extern "C" short    poly_zero(struct poly * r);
  79. extern "C" short    poly_copy(struct poly * r, struct poly * a);
  80. extern "C" short     poly_eval(double * r, double x, struct poly * a);
  81. extern "C" short     poly_add(struct poly * r, struct poly * a, struct poly * b);
  82. extern "C" short     poly_sub(struct poly * r, struct poly * a, struct poly * b);
  83. extern "C" short     poly_mult(struct poly * r, struct poly * a, struct poly * b);
  84. extern "C" short     poly_div(struct poly * r, struct poly * a, struct poly * b, struct poly * m);
  85. extern "C" short     poly_lin_change(struct poly * r, struct poly * a, double ycoeff, double c, double * temp1, double * temp2);
  86. extern "C" short     poly_deriv(struct poly * r, struct poly * a);
  87. extern "C" short     poly_integ(struct poly * r, struct poly * a);
  88. extern "C" short     poly_cpx_convert(struct polyx * r, struct poly * a);
  89. extern "C" short    poly_cpx_zero(struct polyx * r);
  90. extern "C" short    poly_cpx_copy(struct polyx * r, struct polyx * a);
  91. extern "C" short     poly_cpx_eval(struct _complex * r, struct _complex * x, struct polyx * a);
  92. extern "C" short     poly_cpx_add(struct polyx * r, struct polyx * a, struct polyx * b);
  93. extern "C" short     poly_cpx_sub(struct polyx * r, struct polyx * a, struct polyx * b);
  94. extern "C" short     poly_cpx_mult(struct polyx * r, struct polyx * a, struct polyx * b);
  95. extern "C" short     poly_cpx_div(struct polyx * r, struct polyx * a, struct polyx * b, struct polyx * m);
  96. extern "C" short     poly_cpx_lin_change(struct polyx * r, struct polyx * a, struct _complex * ycoeff, struct _complex * c, 
  97.                 struct _complex * temp1, struct _complex * temp2);
  98. extern "C" short     poly_cpx_deriv(struct polyx * r, struct polyx * a);
  99. extern "C" short     poly_cpx_integ(struct polyx * r, struct polyx * a);
  100. extern "C" short     poly_cpx_root(struct _complex * r, double * c, struct polyx * a, struct _complex * guess);
  101. extern "C" short     poly_cpx_roots(struct _complex * r, double * c, struct polyx * a, struct polyx * tmp, struct polyx * tmp2, struct polyx * tmp3);
  102. extern "C" short    vec_zero(double * r, short n);
  103. extern "C" short     vec_copy(double * r, double * a, short n);
  104. extern "C" short     vec_add(double * r, double * a, double * b, short na);
  105. extern "C" short     vec_sub(double * r, double * a, double * b, short na);
  106. extern "C" short     vec_scalar(double * r, double * a, double x, short na);
  107. extern "C" short     vec_unit(double * r, double * a, short na);
  108. extern "C" short     vec_dotprod(double * r, double * a, double * b, short nab);
  109. extern "C" short     vec_crossprod(double * r, double * a, double * b);
  110. extern "C" short    vec_total(double * r, short n, short n_inputs, double * a, double afactor, ...);
  111. extern "C" short    vec_angle(double * r, double * a, double * b, short n);
  112. extern "C" short    vec_magnitude(double * r, double * a, short n);
  113. extern "C" short    vec_gendotprod(double * r, char * a, char * b, short na, short a_inc, short b_inc);
  114. extern "C" short    mat_zero(double * r, short nr, short nc);
  115. extern "C" short    mat_copy(double * r, double * a, short nr, short nc);
  116. extern "C" short    mat_ident(double * r, short n);
  117. extern "C" short    mat_add(double * r, double * a, double * b, short nr, short nc);
  118. extern "C" short    mat_sub(double * r, double * a, double * b, short nr, short nc);
  119. extern "C" short    mat_scalar(double * r, double * a, double x, short nr, short nc);
  120. extern "C" short    mat_mult(double * r, double * a, double * b, short arows, short acols, short bcols);
  121. extern "C" short    mat_trace(double * t, double * r, short n);
  122. extern "C" short    mat_transpose(double * r, short nr, short nc, double * a);
  123. extern "C" short    mat_lud(double * r, short n, short * row_pivots, short * dsign, double * temp, struct tenbytes * temp2);
  124. extern "C" short    mat_determinant(double * r, short n, short * row_pivots, double * d, short dsign);
  125. extern "C" short    mat_inverse(double * r, double * a, short n, short * row_pivots, double * tmp1, double * tmp2);
  126. extern "C" short mat_inverse_errest(double * r, double * orig_a, double * a, short n, short * row_pivots, double * resid, double * err,
  127.              double * tmp1, double * tmp2, double * tmp3, double * tmp4);
  128. extern "C" short    mat_solve(double * a, short n, short * row_pivots, double * x, double * b);
  129. extern "C" short mat_errest(double * orig_a, double * a, short n, short * row_pivots, double * x, double * b, double * resid, double * err,
  130.                  double * tmp1, double * tmp2);
  131. extern "C" short    mat_colop(double * r, short nr, short nc, short change_col, double x, short from_col);
  132. extern "C" short    mat_rowop(double * r, short nr, short nc, short change_row, double x, short from_row);
  133. extern "C" short    mat_zero_p(double * r, short nr, short nc, short rsiz_c);
  134. extern "C" short    mat_copy_p(double * r, double * a, short nr, short nc, short rsiz_c, short asiz_c);
  135. extern "C" short    mat_ident_p(double * r, short n, short rsiz_c);
  136. extern "C" short    mat_add_p(double * r, double * a, double * b, short nr, short nc, short rsiz_c, short asiz_c, short bsiz_c);
  137. extern "C" short    mat_sub_p(double * r, double * a, double * b, short nr, short nc, short rsiz_c, short asiz_c, short bsiz_c);
  138. extern "C" short    mat_scalar_p(double * r, double * a, double x, short nr, short nc, short rsiz_c, short asiz_c);
  139. extern "C" short    mat_mult_p(double * r, double * a, double * b, short arows, short acols, short bcols, short rsiz_c, short asiz_c, short bsiz_c);
  140. extern "C" short    mat_trace_p(double * t, double * r, short n, short rsiz_c);
  141. extern "C" short    mat_transpose_p(double * r, short nr, short nc, double * a, short rsiz_c, short asiz_c);
  142. extern "C" short    mat_lud_p(double * r, short n, short * row_pivots, short * dsign, double * temp, struct tenbytes * temp2, short rsiz_c);
  143. extern "C" short    mat_determinant_p(double * r, short n, short * row_pivots, double * d, short dsign, short rsiz_c);
  144. extern "C" short    mat_inverse_p(double * r, double * a, short n, short * row_pivots, double * tmp1, double * tmp2, short rsiz_c, short asiz_c);
  145. extern "C" short mat_inverse_errest_p(double * r, double * orig_a, double * a, short n, short * row_pivots, double * resid, double * err,
  146.                double * tmp1, double * tmp2, double * tmp3, double * tmp4,
  147.                short rsiz_c, short orig_a_siz_c, short asiz_c);
  148. extern "C" short    mat_solve_p(double * a, short n, short * row_pivots, double * x, double * b, short rsiz_c);
  149. extern "C" short mat_errest_p(double * orig_a, double * a, short n, short * row_pivots, double * x, double * b, double * resid, double * err,
  150.                  double * tmp1, double * tmp2, short orig_a_siz_c, short asiz_c);
  151. extern "C" short    mat_colop_p(double * r, short nr, short nc, short change_col, double x, short from_col, short rsiz_c);
  152. extern "C" short    mat_rowop_p(double * r, short nr, short nc, short change_row, double x, short from_row, short rsiz_c);
  153. extern "C" short    binary_search_i(double * x, short n, double xi);
  154. extern "C" short    binary_search(double * x, short n, double xi);
  155. extern "C" short    heap_sort(double * x, short n, double ** others, short n_others);
  156. extern "C" short    cubic_spline(double * x, double * y, double * y2, double * temp, short n);
  157. extern "C" short    cubic_spline_int(double * x, double * y, double * y2, short n, double xi, double * yi);
  158.  
  159. // Error recovery versions:
  160. extern "C" short    sincos_e(double theta, double * s, double * c);
  161. extern "C" short     cpx_add_e(struct _complex * r, struct _complex * a, struct _complex * b);
  162. extern "C" short     cpx_sub_e(struct _complex * r, struct _complex * a, struct _complex * b);
  163. extern "C" short     cpx_mult_e(struct _complex * r, struct _complex * a, struct _complex * b);
  164. extern "C" short     cpx_div_e(struct _complex * r, struct _complex * a, struct _complex * b);
  165. extern "C" short    cpx_abs_e(double * a, struct _complex * c);
  166. extern "C" short    cpx_argument_e(double * a, struct _complex * c);
  167. extern "C" short    cpx_convert_e(struct _complex * c, double abs, double arg);
  168. extern "C" short     cpx_sqrt_e(struct _complex * r, struct _complex * a);
  169. extern "C" short     cpx_power_e(struct _complex * r, struct _complex * a, double exp);
  170. extern "C" short     cpx_cpx_power_e(struct _complex * r, struct _complex * a, struct _complex * exp);
  171. extern "C" short    cpx_exp_e(struct _complex * r, struct _complex * a);
  172. extern "C" short     cpx_ln_e(struct _complex * r, struct _complex * a);
  173. extern "C" short     cpx_sin_e(struct _complex * r, struct _complex * a);
  174. extern "C" short     cpx_cos_e(struct _complex * r, struct _complex * a);
  175. extern "C" short    poly_zero_e(struct poly * r);
  176. extern "C" short    poly_copy_e(struct poly * r, struct poly * a);
  177. extern "C" short     poly_eval_e(double * r, double x, struct poly * a);
  178. extern "C" short     poly_add_e(struct poly * r, struct poly * a, struct poly * b);
  179. extern "C" short     poly_sub_e(struct poly * r, struct poly * a, struct poly * b);
  180. extern "C" short     poly_mult_e(struct poly * r, struct poly * a, struct poly * b);
  181. extern "C" short     poly_div_e(struct poly * r, struct poly * a, struct poly * b, struct poly * m);
  182. extern "C" short     poly_lin_change_e(struct poly * r, struct poly * a, double ycoeff, double c, double * temp1, double * temp2);
  183. extern "C" short     poly_deriv_e(struct poly * r, struct poly * a);
  184. extern "C" short     poly_integ_e(struct poly * r, struct poly * a);
  185. extern "C" short     poly_cpx_convert_e(struct polyx * r, struct poly * a);
  186. extern "C" short    poly_cpx_zero_e(struct polyx * r);
  187. extern "C" short    poly_cpx_copy_e(struct polyx * r, struct polyx * a);
  188. extern "C" short     poly_cpx_eval_e(struct _complex * r, struct _complex * x, struct polyx * a);
  189. extern "C" short     poly_cpx_add_e(struct polyx * r, struct polyx * a, struct polyx * b);
  190. extern "C" short     poly_cpx_sub_e(struct polyx * r, struct polyx * a, struct polyx * b);
  191. extern "C" short     poly_cpx_mult_e(struct polyx * r, struct polyx * a, struct polyx * b);
  192. extern "C" short     poly_cpx_div_e(struct polyx * r, struct polyx * a, struct polyx * b, struct polyx * m);
  193. extern "C" short     poly_cpx_lin_change_e(struct polyx * r, struct polyx * a, struct _complex * ycoeff, struct _complex * c, 
  194.                 struct _complex * temp1, struct _complex * temp2);
  195. extern "C" short     poly_cpx_deriv_e(struct polyx * r, struct polyx * a);
  196. extern "C" short     poly_cpx_integ_e(struct polyx * r, struct polyx * a);
  197. extern "C" short     poly_cpx_root_e(struct _complex * r, double * c, struct polyx * a, struct _complex * guess);
  198. extern "C" short     poly_cpx_roots_e(struct _complex * r, double * c, struct polyx * a, struct polyx * tmp, struct polyx * tmp2, struct polyx * tmp3);
  199. extern "C" short    vec_zero_e(double * r, short n);
  200. extern "C" short     vec_copy_e(double * r, double * a, short n);
  201. extern "C" short     vec_add_e(double * r, double * a, double * b, short na);
  202. extern "C" short     vec_sub_e(double * r, double * a, double * b, short na);
  203. extern "C" short     vec_scalar_e(double * r, double * a, double x, short na);
  204. extern "C" short     vec_unit_e(double * r, double * a, short na);
  205. extern "C" short     vec_dotprod_e(double * r, double * a, double * b, short nab);
  206. extern "C" short     vec_crossprod_e(double * r, double * a, double * b);
  207. extern "C" short    vec_total_e(double * r, short n, short n_inputs, double * a, double afactor, ...);
  208. extern "C" short    vec_angle_e(double * r, double * a, double * b, short n);
  209. extern "C" short    vec_magnitude_e(double * r, double * a, short n);
  210. extern "C" short    vec_gendotprod_e(double * r, char * a, char * b, short na, short a_inc, short b_inc);
  211. extern "C" short    mat_zero_e(double * r, short nr, short nc);
  212. extern "C" short    mat_copy_e(double * r, double * a, short nr, short nc);
  213. extern "C" short    mat_ident_e(double * r, short n);
  214. extern "C" short    mat_add_e(double * r, double * a, double * b, short nr, short nc);
  215. extern "C" short    mat_sub_e(double * r, double * a, double * b, short nr, short nc);
  216. extern "C" short    mat_scalar_e(double * r, double * a, double x, short nr, short nc);
  217. extern "C" short    mat_mult_e(double * r, double * a, double * b, short arows, short acols, short bcols);
  218. extern "C" short    mat_trace_e(double * t, double * r, short n);
  219. extern "C" short    mat_transpose_e(double * r, short nr, short nc, double * a);
  220. extern "C" short    mat_lud_e(double * r, short n, short * row_pivots, short * dsign, double * temp, struct tenbytes * temp2);
  221. extern "C" short    mat_determinant_e(double * r, short n, short * row_pivots, double * d, short dsign);
  222. extern "C" short    mat_inverse_e(double * r, double * a, short n, short * row_pivots, double * tmp1, double * tmp2);
  223. extern "C" short mat_inverse_errest_e(double * r, double * orig_a, double * a, short n, short * row_pivots, double * resid, double * err,
  224.              double * tmp1, double * tmp2, double * tmp3, double * tmp4);
  225. extern "C" short    mat_solve_e(double * a, short n, short * row_pivots, double * x, double * b);
  226. extern "C" short mat_errest_e(double * orig_a, double * a, short n, short * row_pivots, double * x, double * b, double * resid, double * err,
  227.                  double * tmp1, double * tmp2);
  228. extern "C" short    mat_colop_e(double * r, short nr, short nc, short change_col, double x, short from_col);
  229. extern "C" short    mat_rowop_e(double * r, short nr, short nc, short change_row, double x, short from_row);
  230. extern "C" short    mat_zero_p_e(double * r, short nr, short nc, short rsiz_c);
  231. extern "C" short    mat_copy_p_e(double * r, double * a, short nr, short nc, short rsiz_c, short asiz_c);
  232. extern "C" short    mat_ident_p_e(double * r, short n, short rsiz_c);
  233. extern "C" short    mat_add_p_e(double * r, double * a, double * b, short nr, short nc, short rsiz_c, short asiz_c, short bsiz_c);
  234. extern "C" short    mat_sub_p_e(double * r, double * a, double * b, short nr, short nc, short rsiz_c, short asiz_c, short bsiz_c);
  235. extern "C" short    mat_scalar_p_e(double * r, double * a, double x, short nr, short nc, short rsiz_c, short asiz_c);
  236. extern "C" short    mat_mult_p_e(double * r, double * a, double * b, short arows, short acols, short bcols, short rsiz_c, short asiz_c, short bsiz_c);
  237. extern "C" short    mat_trace_p_e(double * t, double * r, short n, short rsiz_c);
  238. extern "C" short    mat_transpose_p_e(double * r, short nr, short nc, double * a, short rsiz_c, short asiz_c);
  239. extern "C" short    mat_lud_p_e(double * r, short n, short * row_pivots, short * dsign, double * temp, struct tenbytes * temp2, short rsiz_c);
  240. extern "C" short    mat_determinant_p_e(double * r, short n, short * row_pivots, double * d, short dsign, short rsiz_c);
  241. extern "C" short    mat_inverse_p_e(double * r, double * a, short n, short * row_pivots, double * tmp1, double * tmp2, short rsiz_c, short asiz_c);
  242. extern "C" short mat_inverse_errest_p_e(double * r, double * orig_a, double * a, short n, short * row_pivots, double * resid, double * err,
  243.                double * tmp1, double * tmp2, double * tmp3, double * tmp4,
  244.                short rsiz_c, short orig_a_siz_c, short asiz_c);
  245. extern "C" short    mat_solve_p_e(double * a, short n, short * row_pivots, double * x, double * b, short rsiz_c);
  246. extern "C" short mat_errest_p_e(double * orig_a, double * a, short n, short * row_pivots, double * x, double * b, double * resid, double * err,
  247.                  double * tmp1, double * tmp2, short orig_a_siz_c, short asiz_c);
  248. extern "C" short    mat_colop_p_e(double * r, short nr, short nc, short change_col, double x, short from_col, short rsiz_c);
  249. extern "C" short    mat_rowop_p_e(double * r, short nr, short nc, short change_row, double x, short from_row, short rsiz_c);
  250. extern "C" short    binary_search_i_e(double * x, short n, double xi);
  251. extern "C" short    binary_search_e(double * x, short n, double xi);
  252. extern "C" short    heap_sort_e(double * x, short n, double ** others, short n_others);
  253. extern "C" short    cubic_spline_e(double * x, double * y, double * y2, double * temp, short n);
  254. extern "C" short    cubic_spline_int_e(double * x, double * y, double * y2, short n, double xi, double * yi);
  255.  
  256. #endif
  257.  
  258.